package com.example.widgetapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private Button button1,button2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main1);

        button1 = findViewById(R.id.but1);
        button1.setOnClickListener(this);
        /*button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d("Mainactivity","你好，but1");
            }
        });*/

        button2 = findViewById(R.id.but2);
        button2.setOnClickListener(this);
        /*button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d("Mainactivity","你好，but2");
            }
        });*/
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.but1:
                Toast.makeText(MainActivity.this,"登陆成功",Toast.LENGTH_SHORT).show();/*显示弹窗*/
            break;
            case R.id.but2:
                /*Log.d("Mainactivity","你好，肖宇梁");*/
                Toast.makeText(MainActivity.this,"注册成功",Toast.LENGTH_SHORT).show();
            default:
                break;
        }
    }

}